#include <asm.h>
#include <regdef.h>
#include <new_inst_test.h>

LEAF(my9_movz_test)
    .set noreorder
    addiu s0, s0 ,1
    addiu s2, zero, 0x0
    lui   t2, 0x1
###test inst

    Test_Rtype(movz,0x3b1,0x3b1,0x0);
    Test_Rtype(movz,0x126,0x126,0x0);
    Test_Rtype(movz,0x1b0,0x1b0,0x0);
    Test_Rtype(movz,0xafe98c,0xafe98c,0x0);
    Test_Rtype(movz,0x19f,0x19f,0x0);

    TEST_MOVZ_FALSE(0x213452)
    TEST_MOVZ_FALSE(0x236ba4)
    TEST_MOVZ_FALSE(0xffffc396)
    TEST_MOVZ_FALSE(0x190d78)
    TEST_MOVZ_FALSE(0x353a8a)
    TEST_MOVZ_FALSE(0x24c876)

    TEST_MOVZ_TRUE(0x12343)
    TEST_MOVZ_TRUE(0xed6ac)
    TEST_MOVZ_TRUE(0x25708)
    TEST_MOVZ_TRUE(0x730685)

    LI (t0,0x111111);
    LI (t1,0x111112);
    LI (t2,0x111113);
    LI (t3,0x111114);
    LI (t4,0x111115);
    movz t5,t0,zero;
    movz t6,t1,zero;
    movz t7,t2,zero;
    movz t8,t3,zero;
    movz t4,t0,t4;
    is_reg_equ_to_imm(t5,t0,0x111111);
    is_reg_equ_to_imm(t6,t0,0x111112);
    is_reg_equ_to_imm(t7,t0,0x111113);
    is_reg_equ_to_imm(t8,t0,0x111114);
    is_reg_equ_to_imm(t4,t0,0x111115);

###detect exception
    bne s2, zero, inst_error
    nop
###score ++
    addiu s3, s3, 1
###output (s0<<24)|s3
test:
    beq s0,s3,inst_error
    nop
    addiu s3,s3,1
    j test
    nop
inst_error:
    sll t1, s0, 24
    or t0, t1, s3
    sw t0, 0(s1)
    jr ra
    nop
END(my9_movz_test)
